from functools import reduce
class Solution:
    def addTwoNumbers(self, l1, l2):
        """
        :type l1: ListNode
        :type l2: ListNode
        :rtype: ListNode
        """
        def LtoL(listNode):
            l = []
            while listNode:
                l.append(listNode.val)
                listNode = listNode.next
            return l[::-1]
        l1 = LtoL(l1)
        l2 = LtoL(l2)
        def Sum(sum,lists):
            sum = sum*10 + lists
            return sum
        r1 = reduce(Sum,l1)
        r2 = reduce(Sum,l2)
        r3 = r1 + r2
        r3 = str(r3)
        def char_toInt(x):
            x = int(x)
            return x
        r4 = list(map(char_toInt,r3))
        return r4[::-1]
#这是我参考了度娘的代码，首先将链表转换成列表进行运算，链表我不熟，然后进行逆向输出方便计算
#再利用reduce函数进行列表累积